import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export let useProtect = defineStore('showProtect', () => {

    let show_protect = ref(false);

    let open_change = ref(1);

  



    let cur_subproject_id = ref("0");

    let cur_month = ref("1"); //1-12

    let subproject_id_getter = computed(() => cur_subproject_id.value);
    let cur_month_getter = computed(() => cur_month.value);

    let show_protect_getter = computed(() => show_protect.value);

    let open_change_getter = computed(() => open_change.value);

    function show_protect_fn(status) {
        show_protect.value = status   //必须使用.value
    };

    function cur_subproject_id_fn(status) {
        cur_subproject_id.value = status   //必须使用.value
    }

    function cur_month_fn(data) {
        cur_month.value = data   //必须使用.value
    }


    function open_change_fn() {
        open_change.value = Math.random();
    }

  

    let obj = ref({});//携带组件默认数据

    let obj_getter = computed(() => obj.value);

    function obj_fn(datas) {
        obj.value = datas;
    }


    return { subproject_id_getter, cur_month_getter, show_protect_getter, show_protect_fn, cur_subproject_id_fn, cur_month_fn, open_change_fn, open_change_getter,obj_getter,obj_fn }

});
